<template>
  <div>
    <el-dialog title="菜单角色:" :visible.sync="dialogVisible" width="600px">
      <el-table :data="list" height="500" border style="width: 100%">
        <el-table-column prop="roleName" label="角色名称" align="center">
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
          <el-button type="text" @click="remove(scope.row)">解除绑定</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import apisystemmenu from "@/api/baseManager/systemmenu";
import {confirm} from "@/utils/index"
export default {
  name: "dialogSeeMenuAuth",
  data() {
    return {
      dialogVisible: false,
      list: [],
      purviewId: "",
      title:''
    };
  },

  methods: {
    getList(){
       apisystemmenu.getListRoleNameByMenuId(this.purviewId).then(res => {
        this.list = res.data.list;
      });
    },
    menuRole(row) {
      this.purviewId = row.purviewId
      this.title = row.purviewName
      this.dialogVisible = true
      this.getList()
    },
    remove(row){ //解除绑定
      confirm('确定解绑？').then(()=>{
        apisystemmenu.bindRoleAndMenu({roleId:row.roleId,purviewId:this.purviewId}).then(res=>{
          this.$message({type:"success",message:"操作成功！"});
          this.getList()  
        })
      })
    }
  }
};
</script>

<style scoped>
</style>